package game.states 
{
	import assets.Assets;
	import game.entities.Player;
	import game.MyTileMap;
	import org.axgl.Ax;
	import org.axgl.AxGroup;
	import org.axgl.AxState;
	/**
	 * ...
	 * @author Pierre Chamberlain
	 */
	public class StateGame extends AxState
	{
		private var _map:MyTileMap;
		
		public var entities:AxGroup;
		public var player:Player;
		
		public override function create():void 
		{
			super.create();
			
			entities =	new AxGroup();
			
			_map = new MyTileMap(Assets.IMG_TILE_LEVEL_01_BG, Assets.IMG_TILE_LEVEL_01_FG);
			
			add(_map.mapBackground);
			add(entities);
			add(_map.mapForeground);
			
			Ax.camera.bounds.x =		0;
			Ax.camera.bounds.y =		0;
			Ax.camera.bounds.width =	_map.mapBackground.width;
			Ax.camera.bounds.height =	_map.mapBackground.height;
			
			player =	new Player(100, 100);
			entities.add( player );
		}
		
		public override function update():void 
		{
			super.update();
			
			player.isInWater = false;
			
			Ax.collide(entities, _map.mapBackground);
			Ax.overlap(player, _map.mapForeground);
		}
	}
}